|
|
|
|
|
|
|
In this line, oldDatabase is the name (including path) of the database to be compacted; NewDatabase is the name (including path) of the new, compacted database; and locale is the language in which the data is written. Options can be added to encrypt or decrypt a database, as well as to change versions. Multiple options must be joined with the plus (+) sign. |
|
|
|
|
|
|
|
|
Add another button to the PRJMSJET.VBP project. Set its Name property to cmdDBCompact and its Caption property to &DBCompact. Enter the code in Listing 9.4 into the cmdDBCompact_Click event window. This code compacts any Microsoft Jet database. |
|
|
|
|
|
|
|
|
Listing 9.4. Coding the cmdDBCompact_Click event. |
|
|
|
|
|
|
|
|
Private Sub cmdDBCompact_Click()
'
' compact/convert an MS db
'
Dim strOldDBName As String
Dim strNewDBName As String
Dim intEncrypt As Integer
Dim strVersion As String
Dim intVersion As Integer
Dim strHeader As String
'
DBCompactStart:
'
' init vars
strOldDBName = ""
strNewDBName = ""
strVersion = ""
strHeader = "Compact Database Example"
'
' get db to read
CommonDialog1.DialogTitle = "Open Database to Convert"
CommonDialog1.Filter = "MS Jet | *.mdb"
CommonDialog1.ShowOpen
strOldDBName = CommonDialog1.filename
'
If Trim(strOldDBName) = "" Then Exit Sub
'
' get new name to write
CommonDialog1.DialogTitle = "Open Database to Write"
CommonDialog1.Filter = "MS Jet | *.mdb"
CommonDialog1.filename = "TDP_Fixed.mdb"
CommonDialog1.ShowOpen
strNewDBName = CommonDialog1.filename
'
If Trim(strNewDBName) = "" Then GoTo DBCompactStart
'
' get target version (must be same or higher!)
dbVersion:
intVersion = 0 |
|
|
|
|
|